package com.ly.ocw.service.weixin;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.ly.ocw.comm.MyPage;
import com.ly.ocw.entity.weixin.WeixinCardTestwhitelist;
import com.ly.ocw.repository.weixin.WeixinCardTestwhitelistDao;

/**
 * 
 * 
 * @author Peter
 */
// Spring Service Bean的标识.
@Component
public class WeixinCardTestwhitelistService {

	private static Logger logger = LoggerFactory.getLogger(WeixinCardTestwhitelistService.class);

	@Autowired
	private WeixinCardTestwhitelistDao weixinCardTestwhitelistDao;

	public WeixinCardTestwhitelist getById(Long id) {
		return weixinCardTestwhitelistDao.getById(id);
	}

	public List<WeixinCardTestwhitelist> getAllByWeixinPublicId(Long weixinPublicId) {
		return weixinCardTestwhitelistDao.getAllByWeixinPublicId(weixinPublicId);
	}

	/**
	 * 分页查询
	 * 
	 * @param overtime
	 * @param pageStart
	 * @param pageSize
	 * @return
	 */
	public MyPage<WeixinCardTestwhitelist> searchPage(WeixinCardTestwhitelist weixinCardTestwhitelist, int currentPage, int pageSize) {
		MyPage<WeixinCardTestwhitelist> myPage = new MyPage<WeixinCardTestwhitelist>();

		Long count = weixinCardTestwhitelistDao.searchCount(weixinCardTestwhitelist);

		int pageStart = (currentPage - 1) < 0 ? 0 : (currentPage - 1) * pageSize;
		List<WeixinCardTestwhitelist> list = weixinCardTestwhitelistDao.searchPage(weixinCardTestwhitelist, pageStart, pageSize);

		myPage.setCount(count);
		myPage.setContent(list);

		return myPage;
	}

	public void save(WeixinCardTestwhitelist weixinCardTestwhitelist) {
		weixinCardTestwhitelistDao.save(weixinCardTestwhitelist);
	}

	public void update(WeixinCardTestwhitelist weixinCardTestwhitelist) {
		weixinCardTestwhitelistDao.update(weixinCardTestwhitelist);
	}

	/**
	 * 软删除
	 */
	public void delete(Long id) {
		weixinCardTestwhitelistDao.delete(id);
	}

	public void deleteAllByWeixinId(Long publicId) {
		weixinCardTestwhitelistDao.deleteAllByWeixinId(publicId);
		
	}
}
